package com.vmove.childtrain.view.interpolator;


import android.view.animation.Interpolator;

import com.vmove.childtrain.view.interpolator.EasingType.Type;

public class QuartInterpolator implements Interpolator {

	private Type type;

	public QuartInterpolator(Type type) {
		this.type = type;
	}

	public float getInterpolation(float t) {
		if (type == Type.IN) {
			return in(t);
		} else
		if (type == Type.OUT) {
			return out(t);
		} else
		if (type == Type.INOUT) {
			return inout(t);
		}
		return 0;
	}

	private float in(float t) {
		return t*t*t*t;
	}
	private float out(float t) {
		return -((t-=1)*t*t*t - 1);
	}
	private float inout(float t) {
		t *= 2;
		if (t < 1) {
			return 0.5f*t*t*t*t;
		} else {
			return -0.5f * ((t-=2)*t*t*t - 2);
		}
	}
}
